# NXCC freeswitch dockerfile
FROM debian:bullseye
LABEL Author="chun.long"
ARG fs_version
ARG signalwire_token
# gobal configuration
ENV DEBIAN_FRONTEND="noninteractive" \
    LSB_RELEASE="bullseye"  FSTOKEN=${signalwire_token}

# utf8 support,locale-gen en_US.UTF-8,set locale,disable mouse for vim
RUN apt-get update  \
    && apt-get install -y --assume-yes apt-utils dialog whiptail locales vim \
    && sed -e 's/# en_US.UTF-8/en_US.UTF-8/' -i /etc/locale.gen  \
    && /usr/sbin/locale-gen && locale -a  \
    && echo export LC_ALL=en_US.UTF-8 >/root/.bashrc && echo "set mouse=" >/root/.vimrc \
# set date zone
    && apt-get install -y tzdata \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 

# configure recordings upload
RUN apt-get install -y --assume-yes apt-utils psmisc ffmpeg python3-pip cron \
    && pip install multidict yarl async_timeout idna_ssl aiosignal aiobotocore pydub lupa requests pyyaml

# Installing freeswitch
RUN echo "machine freeswitch.signalwire.com login signalwire password $FSTOKEN" > /etc/apt/auth.conf \
    && apt-get install -y --assume-yes apt-utils gnupg2 wget lsb-release  \
    && wget --http-user=signalwire --http-password=$FSTOKEN -O /usr/share/keyrings/signalwire-freeswitch-repo.gpg https://freeswitch.signalwire.com/repo/deb/debian-release/signalwire-freeswitch-repo.gpg \
    && echo "deb [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ ${LSB_RELEASE} main \n    \
             \rdeb-src [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ ${LSB_RELEASE} main" > /etc/apt/sources.list.d/freeswitch.list  \
    && apt-get update \
    && apt-get install -y --allow-downgrades --assume-yes apt-utils  \
libfreeswitch1=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-mod-console=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-logfile=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-enum=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-cdr-csv=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-event-socket=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-sofia=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-loopback=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-commands=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-conference=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-db=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-dptools=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-expr=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-fifo=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-hash=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-pgsql=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-voicemail=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-esf=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-fsv=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-valet-parking=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-httapi=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-dialplan-xml=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-dialplan-asterisk=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-spandsp=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-g723-1=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-g729=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-amr=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-h26x=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-sndfile=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-native-file=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-local-stream=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-tone-stream=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-lua=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-say-en=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-meta-vanilla=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-mod-shout=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1   \
freeswitch-mod-opus=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 libopusfile0 \
freeswitch-mod-xml-curl=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-mod-callcenter=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-mod-xml-cdr=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-mod-mariadb=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-v8=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-mod-say-zh=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1 \
freeswitch-mod-tts-commandline=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-mod-sms=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-mod-xml-rpc=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
freeswitch-conf-vanilla=${fs_version}~release~21~a615e85afc~bullseye-1~bullseye+1  \
libsofia-sip-ua0=1.13.15-123~2366f9cf40~bullseye \
    && apt-get install -y --assume-yes apt-utils lua5.2 lua-cjson lua-bitop lua-socket lua-inspect openssl libssl1.1 procps lua-md5 lua-sec

# RUN apt-get install -y --assume-yes apt-utils vim curl wget gnupg ca-certificates sngrep tcpdump socat iputils-ping iproute2 procps psmisc net-tools lrzsz strace

# COPY entrypoint.sh /

# CMD  ["freeswitch","-nonat"]
CMD ["tail","-f","/dev/null"]